﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CIT.WMS.Move
{
    public partial class FrmMateMove : Form
    {
        DataTable dt = new DataTable();
        public FrmMateMove()
        {
            InitializeComponent();
            string sql = @"select top 10 * from mdcdatvhouse where isenable='0' order by createtime desc ";
            dt = Utils.NMS.QueryDataTable(Utils.uContext, sql, new CIT.WMS.MESWcf.CmdParameter[0]);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //if (i == 0)
                //{
                //    DataRow[] drs = dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                //    foreach (DataRow item in drs)
                //    {
                //        btn_virtualMove.Text = item["movename"].ToString();
                //        btn_virtualMove.Tag = item["movecode"].ToString();
                //        btn_virtualMove.Click += btn_Click;
                //        btn_virtualMove.Visible = true;
                //        break;
                //    }
                //}
                if (i == 0)
                {
                    DataRow[] drs =dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_2.Text = item["movename"].ToString();
                        btn_2.Tag = item["movecode"].ToString();
                        btn_2.Click += btn_Click;
                        btn_2.Visible = true;
                        break;
                    }
                }
                if (i == 1)
                {
                    DataRow[] drs = dt.Select(" movecode='" +dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_3.Text = item["movename"].ToString();
                        btn_3.Tag = item["movecode"].ToString();
                        btn_3.Click += btn_Click;
                        btn_3.Visible = true;
                        break;
                    }
                }
                if (i == 2)
                {
                    DataRow[] drs =dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_4.Text = item["movename"].ToString();
                        btn_4.Tag = item["movecode"].ToString();
                        btn_4.Click += btn_Click;
                        btn_4.Visible = true;
                        break;
                    }
                }
                if (i == 3)
                {
                    DataRow[] drs = dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_5.Text = item["movename"].ToString();
                        btn_5.Tag = item["movecode"].ToString();
                        btn_5.Click += btn_Click;
                        btn_5.Visible = true;
                        break;
                    }
                }
                if (i == 4)
                {
                    DataRow[] drs = dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_6.Text = item["movename"].ToString();
                        btn_6.Tag = item["movecode"].ToString();
                        btn_6.Click += btn_Click;
                        btn_6.Visible = true;
                        break;
                    }
                }
                if (i == 5)
                {
                    DataRow[] drs =dt.Select(" movecode='" +dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_7.Text = item["movename"].ToString();
                        btn_7.Tag = item["movecode"].ToString();
                        btn_7.Click += btn_Click;
                        btn_7.Visible = true;
                        break;
                    }
                }
                if (i == 6)
                {
                    DataRow[] drs = dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_8.Text = item["movename"].ToString();
                        btn_8.Tag = item["movecode"].ToString();
                        btn_8.Click += btn_Click;
                        btn_8.Visible = true;
                        break;
                    }
                }
                if (i == 7)
                {
                    DataRow[] drs = dt.Select(" movecode='" + dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_9.Text = item["movename"].ToString();
                        btn_9.Tag = item["movecode"].ToString();
                        btn_9.Click += btn_Click;
                        btn_9.Visible = true;
                        break;
                    }
                }
                if (i == 8)
                {
                    DataRow[] drs = dt.Select(" movecode='" +dt.Rows[i]["movecode"].ToString() + "'");
                    foreach (DataRow item in drs)
                    {
                        btn_10.Text = item["movename"].ToString();
                        btn_10.Tag = item["movecode"].ToString();
                        btn_10.Click += btn_Click;
                        btn_10.Visible = true;
                        break;
                    }
                }
            }
            //加载click事件

        }
        void setBtn(Button btn, DataTable dt, int index)
        {

        }
        private void btn_Click(object sender, EventArgs e)
        {
            FrmCheckUser frmm = new FrmCheckUser();
            frmm.ShowDialog();
            if (frmm.flag)
            {
                Button btn = (Button)sender;
                DataRow[] drs = dt.Select(" movecode='" + btn.Tag.ToString() + "'");
                FrmMateHouseMove frm = new FrmMateHouseMove(drs);
                frm.ShowDialog();
            }
        }

        private void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_virtualMove_Click(object sender, EventArgs e)
        {
            FrmCheckUser frmm = new FrmCheckUser();
            frmm.ShowDialog();
            if (frmm.flag)
            {
                FrmMoveVirtualShelf frm = new FrmMoveVirtualShelf();
                frm.ShowDialog();
            }
        }
    }
}